#include <iostream>
#include <algorithm>

using namespace std;

typedef long long LL;

const int N = 1e5 + 10;
struct node{
	LL x, y, d;
}a[N];

int x1, y1, x2, y2;
int n;

bool cmp(node& x, node& y)
{
	return x.d > y.d;
}

int main()
{
	cin >> x1 >> y1 >> x2 >> y2 >> n;  
	
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i].x >> a[i].y;
		LL _x = abs(a[i].x - x1);
		LL _y = abs(a[i].y - y1);
		a[i].d = _x * _x + _y * _y;
	}
	sort(a + 1, a + 1 + n, cmp);
	LL ret = a[1].d, len_to2 = 0;
	for(int i = 2; i <= n; i++)
	{
		LL _x = a[i - 1].x - x2;
		LL _y = a[i - 1].y - y2;
		len_to2 = max(_x * _x + _y * _y, len_to2);
		ret = min(len_to2 + a[i].d, ret);
	}
	cout << ret << endl;
	return 0;
}
